import { BasicColumn, FormSchema } from "/@/components/Table"
import dictEnum from "/@/enums/dictEnum"
import { AvailableEnum } from '/@/enums'
import { render } from "/@/utils/common/renderUtils"

export const columns: BasicColumn[] = [
  {
    title: "岗位名称",
    dataIndex: "name",
    width: 200,
  },
  {
    title: "岗位标识",
    dataIndex: "code",
    width: 200,
  },

  {
    title: "岗位排序",
    dataIndex: "sortNo",
    width: 100,
  },
  {
    title: "岗位等级",
    dataIndex: "rankName",
    width: 100,
  },
  {
    title: '状态',
    dataIndex: 'status',
    width: 100,
    customRender: ({ text }) => {
      const color = text == AvailableEnum.NORMAL ? "green" : "red"
      return render.renderTag(text == AvailableEnum.NORMAL ? "正常" : "停用", color)
    },
  },
  {
    title: "更新时间",
    dataIndex: "updatedAt",
    width: 160,
  },
  {
    title: "更新者",
    dataIndex: "updatedBy",
    width: 140,
  },
  
]

export const searchFormSchema: FormSchema[] = [
  {
    field: "name",
    label: "岗位名称",
    component: "Input",
    colProps: { span: 8 },
  },
  {
    field: "name",
    label: "岗位标识",
    component: "Input",
    colProps: { span: 8 },
  },
  {
    label: "岗位状态",
    field: "status",
    component: "JDictSelectTag",
    colProps: { span: 8 },
    componentProps: {
      dictType: dictEnum.DataAvailable,
      placeholder: "全部",
      chooseOptionLabel: "全部",
    },
  },
]

export const formSchema: FormSchema[] = [
  {
    label: "主键",
    field: "id",
    component: "Input",
    show: false,
  },
  {
    field: "name",
    label: "岗位名称",
    component: "Input",
    required: true,
  },
  {
    field: "code",
    label: "岗位标识",
    component: "Input",
    required: true,
    dynamicDisabled: ({ values }) => {
      return !!values.id
    },
  },
  {
    label: "岗位职级",
    field: "rank",
    component: "JDictSelectTag",
    required: true,
    componentProps: {
      dictType: dictEnum.PositionRank,
      dropdownStyle: {
        maxHeight: "100vh",
      },
    },
  },
  {
    field: "sortNo",
    label: "排序",
    component: "InputNumber",
    defaultValue: 1,
  },
  {
    label: "备注",
    field: "remark",
    component: "InputTextArea",
    componentProps: {
      placeholder: "请输入备注",
      rows: 5,
    },
  },
]
